package com.htpay.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.htpay.mapper.MerchantLogMapper;
import com.htpay.model.entity.MerchantLog;
import com.htpay.service.IBaseAPIService;
import com.htpay.service.IMerchantLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 系统日志表 服务实现类
 * </p>
 */
@Service
public class MerchantLogServiceImpl extends ServiceImpl<MerchantLogMapper, MerchantLog> implements IMerchantLogService {

    @Resource
    private MerchantLogMapper sysLogMapper;
    @Autowired
    private IBaseAPIService sysBaseAPI;

    /**
     * @功能：清空所有日志记录
     */
    @Override
    public void removeAll() {
        sysLogMapper.removeAll();
    }

    @Override
    public Long findTotalVisitCount() {
        return sysLogMapper.findTotalVisitCount();
    }

    @Override
    public Long findTodayVisitCount(Date dayStart, Date dayEnd) {
        return sysLogMapper.findTodayVisitCount(dayStart, dayEnd);
    }

    @Override
    public Long findTodayIp(Date dayStart, Date dayEnd) {
        return sysLogMapper.findTodayIp(dayStart, dayEnd);
    }

    @Override
    public List<Map<String, Object>> findVisitCount(Date dayStart, Date dayEnd) {
        return sysLogMapper.findVisitCount(dayStart, dayEnd, "MYSQL");
    }
}
